//
//  MovingFrame.m
//  eye_hunter
//
//  Created by cherry on 10-11-7.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MovingFrame.h"


@implementation MovingFrame

@synthesize oriFrame;
@synthesize endFrame;

/**
 *生成一对hit Frame
 */
- (id) initRandomHitFrameAt:(CGPoint) point{
    int sign = [HunterTool randomSign];
    CGFloat dx = STAR_ORI_R - [HunterTool randomInt:(STAR_ORI_R * 2)];
    CGFloat dy = sqrt(STAR_ORI_R*STAR_ORI_R - dx*dx) * sign;
    self.oriFrame = CGRectMake(point.x + dx, point.y + dy, STAR_SIZE, STAR_SIZE);
    dx = dx * STAR_END_R / STAR_ORI_R;
    dy = sqrt(STAR_END_R*STAR_END_R - dx*dx) * sign;
    self.endFrame = CGRectMake(point.x + dx, point.y + dy, STAR_SIZE, STAR_SIZE);
    return self;
}

/**
 *生成一对miss Frame
 */
- (id) initRandomMissFrameAt:(CGPoint) point{
    self.oriFrame = CGRectMake(point.x-STAR_ORI_R, point.y-STAR_ORI_R, STAR_ORI_R*2, STAR_ORI_R*2);
    self.endFrame = CGRectMake(point.x-STAR_END_R, point.y-STAR_END_R, STAR_END_R*2, STAR_END_R*2);
    return self;
}
@end
